# Contributor: lauren n. liberda <lauren@selfisekai.rocks>
# Maintainer: lauren n. liberda <lauren@selfisekai.rocks>
pkgname=dart-stage0
# upgrade checklist: https://md.sdomi.pl/Q-ECZTJ2Qqyp3ahfJuYSBw
pkgver=3.2.0_alpha150-r0
pkgrel=0
pkgdesc="Dart is a client-optimized language for fast apps on any platform (temporary bootstrap package)"
url="https://dart.dev/"
arch="aarch64 armv7 riscv64 x86_64"
license="BSD-3-Clause"
options="!check"

case "$pkgver" in
	*.*.*_alpha*)
		_canonver="${pkgver/_alpha/-}"
		_canonver="${_canonver/-r/.}.dev"
		;;
	*.*.*_beta*)
		_canonver="${pkgver/_beta/-}"
		_canonver="${_canonver/-r/.}.beta"
		;;
	*.*.*)
		_canonver="$pkgver"
		;;
esac

source="
	dart-musl-stage0-x64-$_canonver.tar.gz.noauto::https://github.com/dart-musl/dart/releases/download/$_canonver/dartsdk-linux-x64-release.tar.gz
	dart-musl-stage0-arm-$_canonver.tar.gz.noauto::https://github.com/dart-musl/dart/releases/download/$_canonver/dartsdk-linux-arm-release.tar.gz
	dart-musl-stage0-arm64-$_canonver.tar.gz.noauto::https://github.com/dart-musl/dart/releases/download/$_canonver/dartsdk-linux-arm64-release.tar.gz
	dart-musl-stage0-riscv64-$_canonver.tar.gz.noauto::https://github.com/dart-musl/dart/releases/download/$_canonver/dartsdk-linux-riscv64-release.tar.gz
"
builddir="$srcdir/"

provides="dart-bootstrap=$pkgver-r$pkgrel"
provider_priority=42

case "$CARCH" in
	aarch64) _dart_arch="arm64" ;;
	armv7) _dart_arch="arm" ;;
	riscv64) _dart_arch="riscv64" ;;
	x86_64) _dart_arch="x64" ;;
esac

build() {
	:
}

package() {
	mkdir -p "$pkgdir"/usr/lib "$pkgdir"/usr/bin "$pkgdir"/usr/include
	(
		cd "$pkgdir"/usr/lib
		tar xf "$srcdir"/dart-musl-stage0-$_dart_arch-$_canonver.tar.gz.noauto
		mv dart-sdk dart
	)
	ln -s ../lib/dart/bin/dart "$pkgdir"/usr/bin/dart
	ln -s ../lib/dart/bin/dartaotruntime "$pkgdir"/usr/bin/dartaotruntime
	ln -s ../lib/dart/include "$pkgdir"/usr/include/dart
}

sha512sums="
6fa5e6db8764af8be4c1578823395d2dca309629a144f95ef341b4c583e1ca7380847a2043ffaa0d8a2a3fac4938a88f474d606236a8a67113b5782754654300  dart-musl-stage0-x64-3.2.0-150.0.dev.tar.gz.noauto
024664e5096c4c692a71573a53c7f68c043083fb6fde783b8fe4912f8779ad772fbf3c3bc89ac1130e9f7ff449464482a5f2551688e21c390e9c46e39cf59f03  dart-musl-stage0-arm-3.2.0-150.0.dev.tar.gz.noauto
1cef3ed441c5873aec489edb72bc57a0e5653eb9965de277b631e2e5ef1f84b9b129a4fbc754e57047675b84eddb5fd1efb96561f534e006fb33eaeb62deaf4c  dart-musl-stage0-arm64-3.2.0-150.0.dev.tar.gz.noauto
7e2901498a4ea177bc7f54d9fd8f01ce2f29ee497fcf7e3fee9b7fc19c226b6ebdab11b555c90d9765022d3439256f37aa9f134af3138fa16d861d8f1ca0645a  dart-musl-stage0-riscv64-3.2.0-150.0.dev.tar.gz.noauto
"
